package chapter16;

import java.lang.reflect.Array;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Arrays;

/**
 * Created by lzy
 * Date: 2018/5/16
 *
 * @author lzy
 */
public class ParameterizedArrayType {
    public static void main(String[] args) {

        ClassParameter<Integer> classParameter = new ClassParameter<>();

        Type genericSuperclass = classParameter.getClass().getGenericSuperclass();
        if (genericSuperclass instanceof ParameterizedType) {
            ParameterizedType parameterizedType = (ParameterizedType) genericSuperclass;
            Type[] actualTypeArguments = parameterizedType.getActualTypeArguments();
            Arrays.stream(actualTypeArguments).forEach(System.out::println);
        }

        Integer[] ints = {1,2,3,4,5};
        Double[] doubles = {1.1,2.2,3.3,4.4,5.5};
        Integer[] integers = new ClassParameter<Integer>().f(ints);
        Double[] doubles1 = MethodParameter.f(doubles);


        Integer[] instance = (Integer[]) Array.newInstance(Integer.class, 10);
        Arrays.stream(instance).forEach(System.out::println);


    }
}
